Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Client as an interface #240

Merged

Conversation

josipsumeckispread
Copy link
Contributor

@josipsumeckispread josipsumeckispread commented Oct 30, 2024

Having HTTP Client as an interface allows us to use more complex http client implementations. The one I am personally interested at is github.com/sethgrid/pester which allows us to use resilient requests to remote GraphQL server by implementing a retry strategy on underlying HTTP requests.
The rest of the repository requires no change. All the existing generated code will be compatible with the proposed change.

Example:

package ein

import (
	"context"
	"net/http"
	"time"

	"github.com/sethgrid/pester"

        "github.com/Yamashou/gqlgenc/clientv2"
)

func NewEinHttpClientWithRetry(roundTripper http.RoundTripper) clientv2.HttpClient {
	client := pester.New()
	client.Transport = roundTripper
	client.Timeout = 120 * time.Second
	client.Concurrency = 1
	client.MaxRetries = 5
	client.Backoff = pester.ExponentialJitterBackoff
	client.RetryOnHTTP429 = true
	return client
}

@josipsumeckispread josipsumeckispread force-pushed the feature/http-client-interface branch from 1e1e210 to ac8584f Compare November 4, 2024 17:01
@Yamashou Yamashou merged commit e320159 into Yamashou:master Nov 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants